package com.abe.jmcl.android.retrofit.contract;


import com.abe.jmcl.api.AppMainService;
import com.abe.jmcl.entity.http.city.ChinaEntity;
import com.abeframe.core.base.http.ResultListener;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class XmlCitiesModel implements XmlCitiesContract.Model {
    @Override
    public void getProvince(final ResultListener<ChinaEntity> listener) {
        Call<ChinaEntity> call = AppMainService.getXmlCitiesService().getXmlCities("china");
        call.enqueue(new Callback<ChinaEntity>() {
            @Override
            public void onResponse(Call<ChinaEntity> call, Response<ChinaEntity> response) {
                listener.onSuccess(response.body());
                listener.onEnd();
            }

            @Override
            public void onFailure(Call<ChinaEntity> call, Throwable t) {
                listener.onFailure(t.getMessage());
                listener.onEnd();
            }
        });
    }
}
